package com.blog.applet.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.applet.domain.BlogArticles;
import com.blog.applet.domain.BlogCategories;
import com.blog.applet.mapper.BlogCategoryMapper;
import com.blog.applet.service.BlogCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/***
 * @Author 鳄鱼杆
 * @Date 2025/5/21 20:33
 */
@Service
public class BlogCategoryServiceImpl extends ServiceImpl<BlogCategoryMapper,BlogCategories> implements BlogCategoryService {

    @Autowired
    private BlogCategoryMapper blogCategoryMapper;

    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    public IPage<BlogCategories> selectPage(Integer pageNum, Integer pageSize) {

        //1、处理pageNum和pageSize
        if (pageNum == null || pageNum <= 0) {
            pageNum = 1;
        }
        if (pageSize == null || pageSize <= 0) {
            pageSize = 10;
        }

        // 创建分页对象，第一页，每页5条数据
        Page<BlogCategories> page = new Page<>(pageNum, pageSize);

        return blogCategoryMapper.selectPage(page, null);
    }
}
